﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KBasedNumber.Question;
namespace KBasedNumber.Answer
{
    class Jimson: IKBasedNumber
    {
        public int KBasedNumber(int n, int k)
        {
          
            if (k > 2)
            {
               return (k - 1) * (int)(Math.Pow(k, n - 1) - (n - 2) * Math.Pow(k, n - 3));
            }

            return int.Parse((Math.Pow(k, n) - k).ToString());
        
        }
    }
}
